<template>
  <div id="taskMap-map" style="width:100%;height:658px"></div>
  <div id="taskMap-mapDiv" class="ol-popup">
    <div id="assess-setDivPosition"  class="init-setDivPosition">
			<!-- 切换卫星和街道地图 -->
			<p @click="switchMap" class="init-setDivPosition-selected">
				<template v-if="switchMapBool==false">
					<img src="@/assets/map/image/weixing-b.png" title="切换卫星地图"><br/><span>卫星图</span>
				</template>
				<template v-else>
					<img src="@/assets/map/image/jiedao-b.png" title="切换街道地图"><br/><span>街道图</span>
				</template>
			</p>
			<!-- 返回主界面 -->
			<p @click="zoomDefaultPosition" :class="{ 'init-setDivPosition-selected': zoomDefaultPositionBool==true }">
				<img src="@/assets/map/image/newImage/home.png" title="返回主界面"><br/><span>主界面</span>
			</p>
			<!-- 显示工具箱 -->
			<p @click="showHideToolsBoxDiv" :class="{ 'init-setDivPosition-selected': showHideToolsBox==false }">
				<template v-if="showHideToolsBox">
					<img src="@/assets/map/image/tools.png" title="打开工具箱"><br/><span>工具箱</span>
				</template>
				<template v-else>
					<img src="@/assets/map/image/tools.png" title="关闭工具箱"><br/><span>工具箱</span>
				</template>
			</p>
			<!-- 任务接口 -->
      <p @click="showHideTaskDiv" :class="{ 'init-setDivPosition-selected': showHideTask==false }">
        <img title="新建任务" src="@/assets/map/image/hf_rxdw_r.png"><br/>
        <span id="taskMap-setTaskDiv-span">新建任务</span>
      </p>
      <!-- 是否显示数据图层 -->
      <p @click="isDataLayer" :class="{ 'init-setDivPosition-selected': showHideSurveyBool==false }">
        <template v-if="showHideSurveyBool">
          <img src="@/assets/map/image/fwdisplay.png" title="数据图层"><br/><span style="border:0;font-size: 12px;">数据图层</span>
        </template>
        <template v-else>
          <img src="@/assets/map/image/fwhide.png" title="数据图层"><br/><span style="border:0;font-size: 12px;">数据图层</span>
        </template>
      </p>
  	</div>
		<!-- 任务接口 -->
    <div id="taskMap-taskDiv" class="init-createTaskDiv">
				<div id="taskMap-MeasureToolsDiv1" class="init-AllToolsDivFloat" style="margin: 10px 0 0 10px;">
					<p @click="mapDrawTaskPolygon" style="border:0;margin: 0px;width:80px">
							<img src="@/assets/map/image/icon-多边形.png" title="测量距离（在地图上单击鼠标左键绘制折线，双击完成测量）"><br/><span>多边形</span>
					</p>
					<p @click="circularDraw" style="border:0;margin: 0px;width:80px">
							<img src="@/assets/map/image/icon-圆形.png" title="测量面积（在地图上单击鼠标左键绘制多边形，双击完成测量）"><br/><span>圆形</span>
					</p>
				</div>
				<p class="init-AllToolsDiv-split1"></p>
				<p @click="xzqhSelectTaskPolygon" style="height: 42px;width: 160px;margin-left: 7px;">
					<img src="@/assets/map/image/行政区划.png" style="vertical-align: bottom;margin-left: -98px;">
					<div style="position: relative;top: -29px;">
						<span style="margin-left: 13px;line-height: 0px;">行政区划</span><br/>
						<span style="margin-left: 40px;line-height: 0px;">选择工作区域</span>
					</div>
				</p>
				<p @click="exportTask" style="border:0;">
						<img src="@/assets/map/image/点线面导入.png" style="vertical-align: middle;margin-left: -9px;">
						<span style="margin-left: 10px;">点线面导入</span>
				</p>
		</div>
		<!-- 工具箱 -->
		<div id="taskMap-ToolsBoxDiv" class="init-ToolsBoxDiv">
			<p @click="measureToolBox" :class="{ 'init-setDivPosition-selected': showHideMeasureTool==false }">
				<template v-if="showHideMeasureTool">
					<img title="开启测量工具" src="@/assets/map/image/cel.png"><br/><span>测量</span>
				</template>
				<template v-else>
					<img title="关闭测量工具" src="@/assets/map/image/cel.png"><br/><span>测量</span>
				</template>
			</p>
			<p @click="positionToolBox" :class="{ 'init-setDivPosition-selected': showHidePositionTool==false }">
        <template v-if="showHidePositionTool">
          <img title="开启定位工具" src="@/assets/map/image/dingw.png"><br/><span style="border:0;">定位</span>
        </template>
        <template v-else>
          <img title="关闭定位工具" src="@/assets/map/image/dingw.png"><br/><span style="border:0;">定位</span>
        </template>
      </p>
		</div>
		<!-- 所有工具 -->
    <div id="taskMap-AllToolsDiv" class="init-AllToolsDiv">
      <!-- 测量工具 -->
      <div id="taskMap-MeasureToolsDiv" class="init-AllToolsDivFloat">
        <p @click="measureDistance" :class="{ 'init-setDivPosition-selected': measureDistanceBool==false }">
          <template v-if="measureDistanceBool">
            <img src="@/assets/map/image/jul.png" title="测量距离（在地图上单击鼠标左键绘制折线，双击完成测量）"><br/><span>测量距离</span>
          </template>
          <template v-else>
            <img src="@/assets/map/image/jul.png" title="测量距离（在地图上单击鼠标左键绘制折线，双击完成测量）"><br/><span>测量距离</span>
          </template>
        </p>
        <p class="init-AllToolsDiv-split"></p>
        <p @click="measureArea" :class="{ 'init-setDivPosition-selected': measureAreaBool==false }">
          <template v-if="measureAreaBool">
            <img src="@/assets/map/image/mianj.png" title="测量面积（在地图上单击鼠标左键绘制多边形，双击完成测量）"><br/><span>测量面积</span>
          </template>
          <template v-else>
            <img src="@/assets/map/image/mianj.png" title="测量面积（在地图上单击鼠标左键绘制多边形，双击完成测量）"><br/><span>测量面积</span>
          </template>
        </p>
        <p class="init-AllToolsDiv-split"></p>
        <p @click="stopMeasure" :class="{ 'init-setDivPosition-selected': stopMeasureBool==false }">
          <template v-if="stopMeasureBool">
            <img src="@/assets/map/image/jshz.png" title="取消测量距离或测量面积操作"><br/><span>结束测量</span>
          </template>
          <template v-else>
            <img src="@/assets/map/image/jshz.png" title="取消测量距离或测量面积操作"><br/><span>结束测量</span>
          </template>
        </p>
        <p class="init-AllToolsDiv-split"></p>
        <p @click="clearMeasure" :class="{ 'init-setDivPosition-selected': clearMeasureBool==false }">
          <template v-if="clearMeasureBool">
            <img src="@/assets/map/image/qux.png" title="清空全部测量结果"><br/><span>清空结果</span>
          </template>
          <template v-else>
            <img src="@/assets/map/image/qux.png" title="清空全部测量结果"><br/><span>清空结果</span>
          </template>
        </p>
      </div>
      <!-- 定位工具 -->
      <div id="taskMap-MousePositionDiv">
        <span><img class="init-jingd" src="@/assets/map/image/jingd.png" title="鼠标左键在地图上点击位置的经度值"></span>
        <input id="taskMap-MousePositionLon" type="text" value="">
        <span><img class="init-weid" src="@/assets/map/image/weid.png" title="鼠标左键在地图上点击位置的纬度值"></span>
        <input id="taskMap-MousePositionLat" type="text" value="">
        <p @click="clearPosition" :class="{ 'init-setDivPosition-selected': clearPositionBool==false }">
          <template v-if="clearPositionBool">
            <img src="@/assets/map/image/qux.png" title="清空全部定位点图标"><br/><span>清空结果</span>
          </template>
          <template v-else>
            <img src="@/assets/map/image/qux.png" title="清空全部定位点图标"><br/><span>清空结果</span>
          </template>
        </p>
        <p class="init-AllToolsDiv-split"></p>
        <p @click="addPosition" :class="{ 'init-setDivPosition-selected': addPositionBool==false }">
          <template v-if="addPositionBool">
            <img src="@/assets/map/image/dingwd.png" title="根据经纬度值在地图上添加定位点图标"><br/><span>添加定位点</span>
          </template>
          <template v-else>
            <img src="@/assets/map/image/dingwd.png" title="根据经纬度值在地图上添加定位点图标"><br/><span>添加定位点</span>
          </template>
        </p>
      </div>
			<!-- 右键菜单 -->
			<div id="taskMap-contextMenuDiv" class="init-contextMenuDiv">
				<div id="taskMap-leftContextMenuDiv">
					<ul>
						<li id="taskMap-newTaskContextMenuLi" @click="mapNewTask">
							<span><img style='width:1px;' src=''>&nbsp;新建任务&nbsp;&nbsp;</span>
						</li>
						<li id="taskMap-editAreaContextMenuLi" @click="editPolygon">
							<span><img style='width:1px;' src=''>&nbsp;修改区域&nbsp;&nbsp;</span>
						</li>
						<li id="taskMap-drawEndTaskContextMenuLi" @click="saveEditPolygon">
							<span><img style='width:1px;' src=''>&nbsp;完成修改&nbsp;&nbsp;</span>
						</li>
						<li id="taskMap-delAreaContextMenuLi" @click="deletePolygon">
							<span><img style='width:1px;' src=''>&nbsp;删除区域&nbsp;&nbsp;</span>
						</li>
					</ul>
				</div>
			</div>
			<!-- 右键菜单 -->
			<div id="taskMap-contextMenuCircle" class="init-contextMenuDiv">
				<div id="taskMap-leftContextMenuDiv">
					<ul>
						<li v-show="circleTools" id="taskMap-newTaskContextMenuLi" @click="mapNewTask">
							<span><img style='width:1px;' src=''>&nbsp;新建任务&nbsp;&nbsp;</span>
						</li>
						<li v-show="circleTools" id="taskMap-delAreaContextMenuLi" @click="deletePolygon">
							<span><img style='width:1px;' src=''>&nbsp;删除区域&nbsp;&nbsp;</span>
						</li>
						<li v-show="circleDrawTool" id="taskMap-delAreaContextMenuLi">
							<span><img style='width:1px;' src=''>设置半径(km)</span>
							<input 
								onkeyup="value=value.replace(/[^\d]/g,'') "
								onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))"
								id="drawCircleRadius"
								:value="10"
								name="drawCircleRadius"
								style="width: -webkit-fill-available;"
							>
							<button @click="drawCircleRadius">确定</button>
						</li>
						<li v-show="circleTool" id="taskMap-delAreaContextMenuLi" @click="deletePolygon">
							<span><img style='width:1px;' src=''>&nbsp;删除区域&nbsp;&nbsp;</span>
						</li>
						<li v-show="circleTool" id="taskMap-delAreaContextMenuLi">
							<span><img style='width:1px;' src=''>设置半径(km)</span>
							<input
								onkeyup="value=value.replace(/[^\d]/g,'') "
								onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))"
								id="circleRadius"
								name="circleRadius"
								:value="10"
								style="width: -webkit-fill-available;"
							>
							<button @click="updateCircleRadius">确定</button>
						</li>
					</ul>
				</div>
			</div>
			<!-- 右键设置缓冲区 -->
			<div id="taskMap-contextBufferMenuDiv" class="init-contextMenuDiv">
				<div id="taskMap-leftContextMenuDiv2">
					<ul>
						<li id="taskMap-delAreaContextMenuLi" @click="deletePolygon">
							<span><img style='width:1px;' src=''>&nbsp;删除区域&nbsp;&nbsp;</span>
						</li>
						<li id="taskMap-modifyContextMenuLi">
							<span><img style='width:1px;' src=''>设置缓冲区(km)</span>
							<input v-model="bufferDistance" 
								onkeyup="value=value.replace(/[^\d]/g,'') "
								onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))"
								type="text" style="width: -webkit-fill-available;">
							<button @click="setupBuffer">确定</button>
						</li>
					</ul>
				</div>
			</div>
			<!-- 右键菜单 -->
			<div id="taskMapEx-contextMenuDiv" class="init-contextMenuDiv">
				<div id="taskMap-leftContextMenuDiv2">
					<ul>
						<li id="taskMap-modifyContextMenuLi" @click="mapUpdTask">
							<span><img style='width:1px;' src=''>&nbsp;修改任务&nbsp;&nbsp;</span>
						</li>
						<li id="taskMap-deleteContextMenuLi" @click="mapDelTask">
							<span><img style='width:1px;' src=''>&nbsp;删除任务&nbsp;&nbsp;</span>
						</li>
					</ul>
				</div>
			</div>
    </div>
  </div>
</template>
<script>
import { getProjection,getRESTLayer, getTiandituVecMap, getTiandituVecText, getTiandituImgMap, getTiandituImgText } from "@/map/projMap.js";
import Map from 'ol/Map';
import View from 'ol/View';
import VectorLayer from 'ol/layer/Vector';
import {Vector as VectorSource} from 'ol/source'
import { MapService} from "@supermap/iclient-ol";
import Overlay from 'ol/Overlay';
import Feature from 'ol/Feature';
import GeoJSON from 'ol/format/GeoJSON'
import {getArea, getLength} from 'ol/sphere';
import {Fill, Stroke, Style, Icon, Circle,Text} from 'ol/style';
import {Select, Draw, Modify, Snap, Translate} from 'ol/interaction';
import {unByKey} from 'ol/Observable';
import Point from 'ol/geom/Point';
import MultiPoint from 'ol/geom/MultiPoint';
import Polygon from 'ol/geom/Polygon';
import MultiPolygon from 'ol/geom/MultiPolygon';
import { fromCircle } from 'ol/geom/Polygon';
import CircleDraw from 'ol/geom/Circle';
import {boundingExtent} from 'ol/extent';
import LineString from 'ol/geom/LineString';
import MultiLineString from 'ol/geom/MultiLineString';
import {fromLonLat, transform, toLonLat} from 'ol/proj';
import * as turf from '@turf/turf';
import dingweiImg from '@/assets/map/image/newImage/blueMarker.png';
import pointStyleDraw from '@/assets/map/image/fwType/3.png';

export default ({
    name: 'Map',
		props:{
			districtTreeList: {//行政区划树列表
				type:Array,
				required:true,
				default:[]
			},
			mutifileShpList: {// 导入shp文件解析过后的范围列表
				type: Array,
				required: true,
				default: []
			},
			addLayerData: {
				type: Object,
				required: true,
				default: {}
			},
			taskRegionResultNameCodeList: {//地图圈选查询行政区划结果列表
				type:Array,
				required:false,
				default:[]
			},
			allListData: {//全部查询结果列表
				type:Array,
				required:true,
				default:[]
			},
			// districtTreeList: {//行政区划树列表
			// 	type:Array,
			// 	required:true,
			// 	default:[]
			// },
			layerStyle: {
				type: Boolean,
				required: true,
				default: false
			},
			clearTaskLayer: {
				type: Boolean,
				required: true,
				default: false
			},
		},
		emits:[ 'xzqhSelect', 'mapLoading', 'queryTaskRegionNameCodeListByGeomText', 'mapNewTask',
		 'mapUpdTask', 'mapDelTask', 'uploadShp', 'isDataLayer' ],
    data (){
			return {
				str: 'taskMap',
				map: null,
				center: [105, 34],
				zoom: 4,
				lineALlBuffer: null,//线缓冲
				layer1: null,
				layer2: null,
				layer3: null,
				layer4: null,
				modify:null,
				select: null,
				mapLoadingBool: false,
				selectFeatureLayer: null,
				selectFeature:null,//选中要素
				queryProvinceBool:false,
				queryCityBool:false,
				queryProCityBool:false,//省会城市查询完毕参数
				queryAreaBool:false,
				queryDrawAreaBool:false,//绘制区域点查询完毕参数
				queryDrawAreaPointCount:0,//绘制区域点数量
				switchMapBool: false,
				zoomDefaultPositionBool: true,
				showHideToolsBox: true,
				showHidePositionTool: true,
				measureDistanceBool: true,
				circleTool: false,
				circleTools: false,
				circleDrawTool: true,
				measureAreaBool: true,
				stopMeasureBool: true,
				clearMeasureBool: true,
				clearPositionBool: true,
				addPositionBool: true,
				showHideTask:true,
				showHideSurveyBool: true,
				source: null,
				measureSource: null,
				draw:null,//矢量绘制
				measure:null,//测量工具
				sketch: null,
				helpTooltipElement:null,
				helpTooltip:null,
				measureTooltipElement:null,
				measureTooltip:null,
				measureTooltipArray:[],//全部测量结果Overlay数组
				showHideMeasureTool:true,//显示|隐藏测量工具
				newContextMenu:null,//新建任务右键菜单
				newBufferMenu:null,//新建任务右键菜单
				newCircleMenu: null,
      	taskContextMenu:null,//修改任务右键菜单
				selectTaskRow:null,
				taskArea:null,//新建任务参数--面积
				taskRegion:null,//新建任务参数--经纬度范围
      	parentdistrictList:[],//新建任务参数--行政区划
				parentdistrictNameList:[],//区域查询行政区划名称列表
      	parentdistrictCodeList:[],//区域查询行政区划编码列表
				districtTreeDataList:[],//行政区划树列表
				drawAreaFeature:null,//地图圈选要素
				taskVectorLayer:null,//任务列表区域图层
				circleFeature: null,
				uploadPointTool: false,
				shpList: [],//导入的shp文件
				bufferDistance: 10,//线缓冲距离
				drawState: '',//绘制的类型  圆/线/面/点
				importPoint: [],//导入点的中心点
				dataLayer: {},
				groupDataList: [],
				circlePoint: [],//绘制圆的中心点
				clearFeatureList: [],
				addTaskIsIntersect: false
			}
    },
		watch: {
			mutifileShpList: {// 根据导入shp 绘制图形
				handler: function(newVal,oldVal){
					this.shpList = newVal;
					if(newVal!=oldVal){
						this.drawFace(this.shpList);
					}
				},
				deep:true,
				immediate:true
			},
			addLayerData: {// 添加与移除数据图层
				handler: function(newVal,oldVal){
					this.dataLayer = newVal;
					if(newVal!=oldVal){
						this.addIserverLayer(this.dataLayer);
					}
				},
				immediate: true
			},
			taskRegionResultNameCodeList: {// 地图圈选查询行政区划结果列表
				handler: function(newVal,oldVal){
					this.queryDrawAreaNewResult(newVal);// 新查询绘制区域经纬度任务地区
				},
				immediate:true
			},
			allListData: {// 加载创建的任务
				handler: function(newVal,oldVal){
					this.groupDataList = newVal;
					if(newVal!=oldVal){
						this.showGroupData();
					}
				},
				immediate:true
			},
			districtTreeList: {
				handler: function(newVal,oldVal){
					//行政区划树列表
					this.districtTreeDataList = newVal;
				},
				immediate:true
			},
			layerStyle: {
				handler: function(newVal, oldVal){
					this.showHideSurveyBool = true
				},
				immediate: true
			},
			clearTaskLayer: {
				handler: function(newVal, oldVal) {
					if(newVal) {
						this.clearSource()
					}
				},
				immediate: true
			},
		},
    created(){
        
    },
    mounted(){
			let that = this
			this.$nextTick(function(){
				setTimeout(() => {
					// 初始化地图
					that.initMap()
					// 加载创建的任务
					that.showGroupData()
				}, 200)
			})
    },
    methods: {
			initMap(){
				let that = this
				let mapstr = this.str
				let targetMap = document.getElementById(mapstr + '-map')
				targetMap.innerHTML = ''
				let targetDiv = document.getElementById(mapstr + '-mapDiv')
				let node = document.createElement('div')
				node.id = mapstr + '-popup'
				node.setAttribute('class', 'new-ol-popup')
				node.innerHTML = '<a href="#" id="' + mapstr + '-popup-closer" class="new-ol-popup-closer"></a>' +
						'<div id="' + mapstr + '"-popup-content"></div>'
				// targetDiv.appendChild(node)
				this.mapLoadingBool = true
				this.autodivheight();
				window.onresize = this.autodivheight;
				if (this.map) {
					return
				}
				this.projection4490 = getProjection();
				this.map = new Map({
					target: targetMap.id,
					view: new View({
						center: this.center,
						maxZoom: 18,
						minZoom: 4,
						zoom: that.zoom,
						constrainResolution: true,
						projection: 'EPSG:4490'
					})
				});
				this.layer1 = getTiandituVecMap()
				this.map.addLayer(this.layer1)
				this.layer2 = getTiandituVecText()
				this.map.addLayer(this.layer2)
				this.layer1.setZIndex(0)
				this.layer2.setZIndex(0)
				//任务区域图层
				this.taskVectorLayer = new VectorLayer({
					source: new VectorSource({
						wrapX: false
					}),
					projection: 'EPSG:4490'
				});
				this.map.addLayer(this.taskVectorLayer);
				this.taskVectorLayer.setZIndex(1);
				//矢量绘制图层
				this.source = new VectorSource({
					wrapX: false
				});
				let vectorLayer = new VectorLayer({
					source: that.source,
					projection: 'EPSG:4490'
				});
				this.map.addLayer(vectorLayer);
				vectorLayer.setZIndex(2);
				//测量结果图层
				this.measureSource = new VectorSource({
					wrapX: false
				});
				let measureLayer = new VectorLayer({
					source: that.measureSource,
					projection: 'EPSG:4490'
				});
				this.map.addLayer(measureLayer);
				measureLayer.setZIndex(2);
				// 右键面的菜单列表
				this.newContextMenu = new Overlay({
					element: document.getElementById(this.str + '-contextMenuDiv'),
					positioning: 'center-center'
				})
				this.map.addOverlay(this.newContextMenu)
				document.getElementById(this.str + '-contextMenuDiv').style.display = 'block'
				// 右键修改任务菜单
				this.taskContextMenu = new Overlay({
					element: document.getElementById(this.str + 'Ex-contextMenuDiv'),
					positioning: 'center-center'
				})
				this.map.addOverlay(this.taskContextMenu)
				document.getElementById(this.str + 'Ex-contextMenuDiv').style.display = 'block'
				// 线的缓冲菜单
				this.newBufferMenu = new Overlay({
					element: document.getElementById(this.str + '-contextBufferMenuDiv'),
					positioning: 'center-center'
				})
				this.map.addOverlay(this.newBufferMenu)
				document.getElementById(this.str + '-contextBufferMenuDiv').style.display = 'block'
				// 圆和点的右键菜单
				this.newCircleMenu = new Overlay({
					element: document.getElementById(this.str + '-contextMenuCircle'),
					positioning: 'center-center'
				})
				this.map.addOverlay(this.newCircleMenu)
				document.getElementById(this.str + '-contextMenuCircle').style.display = 'block'
				//右键菜单事件
				this.map.on('contextmenu', function(event){
					event.preventDefault();//屏蔽自带的右键事件
					let pixel = that.map.getEventPixel(event.originalEvent);
					let feature = that.map.forEachFeatureAtPixel(pixel,function(feature){
						//根据像素坐标获取右键选中的地图要素
						return feature;
					});
					if(feature && that.draw==null){
						//取消选中要素
						that.clearSelectFeature();
						//隐藏右键菜单
						that.hideContextMenu();
						let coordinate = that.map.getEventCoordinate(event.originalEvent);
						let temp = feature.getProperties();
						//选中要素
						that.selectFeature = feature;
						if(temp.groupData!=undefined && temp.groupData!=null){//修改任务
							that.selectTaskRow = temp.groupData;//任务row
							//右键菜单--修改任务
							that.taskContextMenu.setPosition(coordinate);
						}else if(temp.area!=undefined && temp.area!=null){//新建任务
							let geometry = feature.getGeometry();
							//获取多边形区域信息
							if (geometry instanceof Polygon || geometry instanceof CircleDraw || geometry instanceof MultiPolygon) {
								//计算面积
								let area = temp.area;
								//设置返回值
								that.taskArea = area.toString();
								let taskRegion = "";
								let pointArr
								if (geometry instanceof CircleDraw) {
									pointArr = fromCircle(geometry).getCoordinates();
								} else {
									pointArr = geometry.getCoordinates();
								}
								if(pointArr[0]!=null && pointArr[0].length>0){
									for(let i=0;i<pointArr[0].length;i++){
										let lonlat = pointArr[0][i];
										if(i>0){
											taskRegion += ";";
										}
										taskRegion += lonlat[0] + ',' + lonlat[1];
									}
								}
								that.taskRegion = taskRegion;
								that.parentdistrictList = temp.parentdistrictList;
								//设置选中样式
								let style = that.getSelectPolyonStyle();
								feature.setStyle(style);
								//右键菜单--新建任务
								if (geometry instanceof CircleDraw) {
									that.circleTool = false
									that.circleTools = true
									that.circleDrawTool = false
									that.newCircleMenu.setPosition(coordinate);
								} else {
									that.newContextMenu.setPosition(coordinate);
								}
							}
						}else if (feature.getGeometry() instanceof LineString || feature.getGeometry() instanceof MultiLineString) {
							that.newBufferMenu.setPosition(coordinate);
							that.createLineString(feature)
						}else if (feature.getGeometry() instanceof Point || feature.getGeometry() instanceof MultiPoint) {
							if(that.measure == null) {
								that.circleTool = true
								that.circleTools = false
								that.circleDrawTool = false
								let pointArr = feature.getGeometry().getCoordinates();
								if (feature.getGeometry() instanceof Point) {
									that.importPoint = pointArr
								}else{
									that.importPoint = pointArr[0]
								}
								// that.importPoint.push(pointArr[0])
								// that.importPoint.push(pointArr[1])
								that.taskRegion = pointArr[0] + ',' + pointArr[1] + ';';
								that.newCircleMenu.setPosition(coordinate);
							}
						}
					}
				});
				this.map.on('click', function(event){
					if(that.modify==null){//不在修改状态
						//取消选中要素
						that.clearSelectFeature();
					}
					let coordinate = that.map.getEventCoordinate(event.originalEvent)
					let pixel = that.map.getEventPixel(event.originalEvent);
					let feature = that.map.forEachFeatureAtPixel(pixel,function(feature){
						//根据像素坐标获取右键选中的地图要素
						return feature;
					});
					if (that.showHidePositionTool == false) {
						document.getElementById(that.str + '-MousePositionLon').value = coordinate[0]
						document.getElementById(that.str + '-MousePositionLat').value = coordinate[1]
					}
					console.log(that.draw)
					console.log(that.drawState)
					if (that.draw != null && that.drawState == 'Circle' ) {
						that.circlePoint = coordinate
						that.circleTool = false
						that.circleTools = false
						that.circleDrawTool = true
						that.newCircleMenu.setPosition(coordinate);
						if (that.draw) {
							that.map.removeInteraction(that.draw);
							that.draw = null;
						}
					} else {
						that.hideContextMenu();
					}
				})
			},
			clearSource() {
				let allSource = this.source.getFeatures()
				allSource.forEach(item => {
					this.clearFeatureList.forEach(it => {
						if(item == it) {
							this.source.removeFeature(item)
						}
					})
				})
				this.clearFeatureList = []
			},
			updateCircleRadius() {
				this.drawCircle('circleRadius',this.importPoint)
			},
			drawCircleRadius(){
				this.drawCircle('drawCircleRadius',this.circlePoint)
			},
			drawCircle(id,poitn) {
				let radius = document.getElementById(id).value
				radius = radius * 1000
				let metersPerUnit = this.map.getView().getProjection().getMetersPerUnit();
				let circleRadius =  radius / metersPerUnit;
				let shape = new CircleDraw(poitn,circleRadius)
				let style = this.getPolyonStyle('red')
				let feature = new Feature({
						geometry: shape,
				});
				feature.setStyle(style)
				// 获取绘制的圆的面积
				let circleArea = fromCircle(feature.getGeometry())
				let area = getArea(circleArea, {projection: 'EPSG:4490'})
				let output = Math.round((area / 1000000) * 100) / 100;
				feature.setProperties({area: output});
				//清空查询行政区划列表
				this.parentdistrictList = [];
				//清空区域查询行政区划名称列表
				this.parentdistrictNameList = [];
				//清空区域查询行政区划编码列表
				this.parentdistrictCodeList = [];
				this.mapLoading("正在查询，请稍候...");
				this.queryDrawAreaNew(feature);
				this.source.addFeature(feature);
				const layer = new VectorLayer({
					source: this.source,
					projection: 'EPSG: 4490'
				})
				this.map.addLayer(layer)
				this.hideContextMenu();
			},
			addIserverLayer(value) {
				let that = this
				if (value.data) {
					if (value.layerState) {// 添加数据图层
						let mapService = new MapService(value.data.url);//根据超图矢量瓦片图层获取图层信息
						let layer
						mapService.getMapInfo(function (serviceResult) {
							if(serviceResult.result!=undefined){
								let mapJSONObj = serviceResult.result;
								let bounds = mapJSONObj.bounds;
								let left = bounds.left;
								let bottom = bounds.bottom;
								let right = bounds.right;
								let top = bounds.top;
								let origin = [left, top];//左上角
								let extent = [left, bottom, right, top];//图层范围
								layer = getRESTLayer(value.data.url,value.data.id,origin,extent,'',10)
								that.map.addLayer(layer)
								that.map.getView().fit(extent, {padding: [100, 100, 100, 100]});
							}
						})
					} else { // 移除数据图层
						let layers = that.map.getLayers()
						let index = -1
						for(let i=0;i<layers.array_.length;i++){
							if (layers.array_[i].values_.source.options) {
								if (value.data.url == layers.array_[i].values_.source.options.url) {
									index = i
								}
							}	
						}
						that.map.removeLayer(layers.array_[index])
					}
				}
			},
			setupBuffer() {
				let buffered = turf.buffer(this.lineALlBuffer, this.bufferDistance, {units: 'kilometers'});
				//创建数据geojson对象和数据源对象
				let format = new GeoJSON();
				//读取geojson数据
				let a = format.readFeature(this.lineALlBuffer);
				let b = format.readFeature(buffered);
				//清空查询行政区划列表
				this.parentdistrictList = [];
				//清空区域查询行政区划名称列表
				this.parentdistrictNameList = [];
				//清空区域查询行政区划编码列表
				this.parentdistrictCodeList = [];
				// 获取绘制的面的面积
				let area = getArea(b.getGeometry(), {projection: 'EPSG:4490'})
				let output = Math.round((area / 1000000) * 100) / 100;
				b.setProperties({area: output});
				this.mapLoading("正在查询，请稍候...");
				//将数据添加数据源的
				this.queryDrawAreaNew(b);
				this.source.addFeature(b);
				//添加图层
				let test= new VectorLayer({source: this.source})
				this.map.addLayer(test);
				this.hideContextMenu();
			},
			createLineString(temp) {
				let geometry = temp.getGeometry()
				//创建缓冲数据
				let pointArr = geometry.getCoordinates();
				this.lineALlBuffer =  turf.lineString(pointArr);
			},
			drawFace(value) {
				let that = this
				if (value.length != 0) {
					for(let i=0;i<value.length;i++){
						let shapeType = value[i].geometry.type
						let feature,shape,style
						if (shapeType == 'Polygon') {
							let coordinates = value[i].geometry.coordinates[0]
							let coordinatesPolygon = new Array();
							//循环遍历将经纬度转到"EPSG:4326"投影坐标系下
							for (var j = 0; j < coordinates.length; j++) {
									var pointTransform = toLonLat([coordinates[j][0], coordinates[j][1]], 'EPSG:3857','EPSG:4326');
									coordinatesPolygon.push(pointTransform);
							}
							shape = new Polygon(value[i].geometry.coordinates)
							//多边形要素类
							style = this.getPolyonStyle('red')
						}else if(shapeType == 'LineString') {
							shape = new LineString(value[i].geometry.coordinates)
							style = this.getPolyonStyle('red')
						}else if(shapeType == 'Point'){
							shape = new Point(value[i].geometry.coordinates)
							style = this.drawPointStyle()
						}else if(shapeType == 'MultiPoint') {
							shape = new MultiPoint(value[i].geometry.coordinates)
							style = this.drawPointStyle()
						}else if(shapeType == 'MultiPolygon') {
							shape = new MultiPolygon([coordinatesPolygon])
							//多边形要素类
							style = this.getPolyonStyle('red')
						}else if(shapeType == 'MultiLineString') {
							shape = new LineStMultiLineStringring(value[i].geometry.coordinates)
							style = this.getPolyonStyle('red')
						}
						feature = new Feature({
								geometry: shape,
						});
						feature.setStyle(style)
						if (shapeType == 'Polygon') {
							//清空查询行政区划列表
							this.parentdistrictList = [];
							//清空区域查询行政区划名称列表
							this.parentdistrictNameList = [];
							//清空区域查询行政区划编码列表
							this.parentdistrictCodeList = [];
							this.mapLoading("正在查询，请稍候...");
							// 获取绘制的面的面积
							let area = getArea(feature.getGeometry(), {projection: 'EPSG:4490'})
					 		let output = Math.round((area / 1000000) * 100) / 100;
							feature.setProperties({area: output});
							this.queryDrawAreaNew(feature)
						}
						this.source.addFeature(feature)
						const layer = new VectorLayer({
							source: this.source,
							projection: 'EPSG: 4490'
						})
						this.map.addLayer(layer)
						let extent = feature.getGeometry().getExtent();
						let allCoordinates = []
						if(extent.length==4){
							//全部经纬度--左下角
							allCoordinates.push([extent[0],extent[1]]);
							//全部经纬度--右上角
							allCoordinates.push([extent[2],extent[3]]);
						}
						this.showBoundingExtent(allCoordinates);//缩放到区域位置
					}
				}
			},
			showBoundingExtent(coordinates){//缩放到区域位置
				console.log("缩放到区域位置");
				if (coordinates!=null && coordinates.length > 1) {
					const extent = boundingExtent(coordinates);
					//this.map.getView().fit(extent, {duration: 1000, padding: [50, 50, 50, 50]});
					this.map.getView().fit(extent, {padding: [50, 50, 50, 50]});
					//获取默认位置
					this.center = this.map.getView().getCenter();
					this.zoom = this.map.getView().getZoom();
				}
			},
			//显示任务列表区域
			showGroupData(){
				if(this.taskVectorLayer!=null){
					this.taskVectorLayer.getSource().clear();//清空
					console.log("显示任务列表区域");
					console.log(this.groupDataList);
					// this.groupDataList = [this.groupDataList[5]]
					if(this.groupDataList!=null && this.groupDataList.length>0){
            let features = [];
						for(let i=0;i<this.groupDataList.length;i++){
							let groupData = this.groupDataList[i];
							let taskRegion = groupData.taskRegion;
							let str = taskRegion.substring(15,taskRegion.length -3)
							let geom = str.split(')),')
							if(taskRegion!=null && taskRegion!=""){
								if(taskRegion.indexOf("MULTIPOLYGON(((")!=-1){//地图绘制区域
									let srtCoode = ''
									for(let a=0;a<geom.length;a++) {
										if(a==0){
											srtCoode += geom[a] + ';'
										} else{
											let data = geom[a].substring(2,geom[a].length)
											if(a == geom.length - 1) {
												srtCoode += data
											}else{
												srtCoode += data + ';'
											}
										}
									}
									let dataList = srtCoode.split(';')
									let listAll = []
									dataList.forEach(item =>{
										let a = item.toString()
										let b = a.split(',')
										listAll.push(b)
									})
									let cooordsList = []
									for(let b=0;b<listAll.length;b++){
										let coordinates = [];
										let arr = listAll[b]
										for(let j=0;j<arr.length;j++){
											let lonlatStr = arr[j].split(" ");
											let lonlat = [];
											lonlat.push(Number(lonlatStr[0]));
											lonlat.push(Number(lonlatStr[1]));
											coordinates.push(lonlat);
										}
										cooordsList.push(coordinates)
									}
									//多边形
									cooordsList.forEach(item =>{
										let featureTmp = new Feature({
											geometry: new Polygon([item])
										});
										//样式
										let style = this.getPolyonStyle("orange");
										featureTmp.setStyle(style);
										//设置属性
										featureTmp.setProperties({groupData: groupData});
										//添加任务区域
										// this.taskVectorLayer.getSource().addFeature(featureTmp);
                    features.push(featureTmp);
									})
								}else{//行政区划选择区域
									console.log("行政区划选择区域");
									let all_coords_str = taskRegion.split(";");
									for(let i=0;i<all_coords_str.length;i++){
										let coords_str = all_coords_str[i].split("MULTIPOLYGON (((")[1].split(")))")[0];
										if(coords_str.indexOf(")), ((")!=-1){
											console.log("多个的面");
										}
										let geometries = coords_str.split(")), ((");
										console.log("geometries: ", geometries.length);
										for (let k = 0;k < geometries.length;k++) {
											let allPointsArr = [];
											if(coords_str.indexOf("), (")!=-1){
												console.log("镂空的面");
											}
											let __coords = geometries[k].split("), (");
											console.log("__coords: ", __coords.length);
											for (let m = 0;m < __coords.length;m++) {
												let _coords = __coords[m].split(", "), points = [];
												for (let n = 0;n < _coords.length;n++) {
													if(_coords[n]!=null && _coords[n]!=""){
														let coord = _coords[n].split(" ");
														let lon = Number(coord[0]), lat = Number(coord[1]);
														let lonlat = [lon, lat];
														points.push(lonlat);
													}
												}
												allPointsArr.push(points);
											}
											console.log(allPointsArr);
											//多边形
											let featureTmp = new Feature({
												geometry: new Polygon(allPointsArr)
											});
											//样式
											let style = this.getPolyonStyle("orange");
											featureTmp.setStyle(style);
											//设置属性
											featureTmp.setProperties({groupData: groupData});
											//添加任务区域
											// this.taskVectorLayer.getSource().addFeature(featureTmp);
                      features.push(featureTmp);
										}
									}
								}
							}
						}
            //添加任务区域
            this.taskVectorLayer.getSource().addFeatures(features);
					}
				}
			},
			//多边形绘制创建任务工作区域
			mapDrawTaskPolygon(){
				//地图工具箱
				this.setMapToolBox('Polygon');
			},
			// 圆形绘制创建任务
			circularDraw() {
				this.setMapToolBox('Circle');
			},
			// 街道图与卫星图切换
			switchMap() {
				if (this.switchMapBool) {// 显示街道图
					this.switchMapBool = false
					if (this.layer1 == null) {
						this.layer1 = getTiandituVecMap()
						this.map.addLayer(this.layer1)
					}
					if (this.layer2 == null) {
						this.layer2 = getTiandituVecText()
						this.map.addLayer(this.layer2)
					}
					this.layer1.setVisible(true);
					this.layer2.setVisible(true);
					this.layer3.setVisible(false);
					this.layer4.setVisible(false);
					this.layer1.setZIndex(0);
					this.layer2.setZIndex(0);
				} else {
					this.switchMapBool = true
					if (this.layer3 == null) {
						this.layer3 = getTiandituImgMap()
						this.map.addLayer(this.layer3)
					}
					if (this.layer4 == null) {
						this.layer4 = getTiandituImgText()
						this.map.addLayer(this.layer4)
					}
					this.layer1.setVisible(false)
					this.layer2.setVisible(false)
					this.layer3.setVisible(true)
					this.layer4.setVisible(true)
					this.layer3.setZIndex(0)
					this.layer4.setZIndex(0)
				}
			},
			zoomDefaultPosition() {// 返回主界面
				this.map.updateSize();
				this.map.getView().setCenter(this.center);
				this.map.getView().setZoom(this.zoom);
				this.zoomDefaultPositionBool = true;
			},
			showHideToolsBoxDiv() {// 显示工具箱
				if (this.showHideToolsBox) {
					this.showHideToolsBox = false
					document.getElementById(this.str + '-ToolsBoxDiv').style.display = 'block'
				} else {
					this.showHideToolsBox = true
					document.getElementById(this.str + '-ToolsBoxDiv').style.display = 'none'
				}
			},
			measureToolBox() {
				// this.closeAllToolsBox("MeasureTool");
				if (this.showHideMeasureTool) {
					this.showHideMeasureTool = false
					document.getElementById(this.str + '-MeasureToolsDiv').style.display = 'block'
				} else {
					this.showHideMeasureTool = true
					document.getElementById(this.str + '-MeasureToolsDiv').style.display = 'none'
				}
			},
			positionToolBox() {
				// this.closeAllToolsBox("PositionTool");
				if (this.showHidePositionTool) {
					this.showHidePositionTool = false
					document.getElementById(this.str + '-MousePositionDiv').style.display = 'block'
				} else {
					this.showHidePositionTool = true
					document.getElementById(this.str + '-MousePositionDiv').style.display = 'none'
				}
			},
			closeAllToolsBox(type) {
				if (type == 'MeasureTool' && this.showHideMeasureTool == false) {// 关闭测量工具
					// this.showHideMeasureTool = true
					document.getElementById(this.str + '-MeasureToolsDiv').style.display = 'none'
					this.clearMeasure();
        	this.clearMeasureBool = true;
				}
				if (type == 'PositionTool' && this.showHidePositionTool == false) {// 关闭定位工具
					// this.showHidePositionTool = true
					document.getElementById(this.str + '-MousePositionDiv').style.display = 'none'
					//清空定位结果
					this.clearPosition();
				}
			},
			measureDistance() {
				if(this.source!=null){
					//地图工具箱--开启测距
					this.setMapToolBox('MeasureDistance');
					//设置样式
					this.measureDistanceBool = false;
					this.measureAreaBool = true;
					this.stopMeasureBool = true;
					this.clearMeasureBool = true;
				}
			},
			measureArea() {
				if(this.source!=null){
					//地图工具箱--开启测面
					this.setMapToolBox('MeasureArea');
					//设置样式
					this.measureAreaBool = false;
					this.measureDistanceBool = true;
					this.stopMeasureBool = true;
					this.clearMeasureBool = true;
				}
			},
			stopMeasure() {
				if(this.source!=null){
					//地图工具箱--停止测量
					this.setMapToolBox('StopMeasure');
					//设置样式
					this.stopMeasureBool = false;
					this.measureDistanceBool = true;
					this.measureAreaBool = true;
					this.clearMeasureBool = true;
				}
			},
			clearMeasure () {
				if(this.source!=null){
					//地图工具箱--清空测量结果
					this.setMapToolBox('ClearMeasure');
					//设置样式
					this.clearMeasureBool = false;
					this.measureDistanceBool = true;
					this.measureAreaBool = true;
					this.stopMeasureBool = true;
				}
			},
			clearPosition() {
				this.clearPositionBool = false;
				this.addPositionBool = true;
				//地图工具箱--清空
				this.setMapToolBox("Clear");
			},
			addPosition () {
				let that = this
				this.clearPositionBool = true
				this.addPositionBool = false
				if (that.source != null) {
					let longitude = document.getElementById(this.str+"-MousePositionLon").value;
					let latitude = document.getElementById(this.str+"-MousePositionLat").value;
					//处理经纬度
					let lonlat = this.getLonLat(longitude,latitude);
					if (lonlat != null) {
						let featureTmp = new Feature({
							geometry: new Point(lonlat)
						});
						let style = that.getPointStyle()
						featureTmp.setStyle(style)
						featureTmp.setProperties({
							type: 'position',
							longitude: longitude,
							latitude: latitude
						})
						that.source.addFeature(featureTmp)
						that.map.getView().setCenter(lonlat)
						that.map.getView().setZoom(12)
					}
				}
			},
			getLonLat(longitude, latitude) {
				let lonlat = null
				if (longitude != null && latitude != null & longitude != '' && latitude != '') {
					let lon = Number(longitude)
					let lat = Number(latitude)
					if (lon > 0 && lon < 180 && lat > 0 && lat < 180) {
						lonlat = [ lon, lat]
					}
				}
				return lonlat
			},
			drawPointStyle() {// 绘制点图形的样式
				let style = new Style({
					image: new Icon({
						src: pointStyleDraw,
						anchor: [0.5, 1]
					}),
				});
				return style;
			},
			getPointStyle(){// 定位点图标样式
				let style = new Style({
					image: new Icon({
						src: dingweiImg,
						anchor: [0.5, 1]
					}),
				});
				return style;
			},
			getPolyonStyle(color){//多边形样式
				let style = new Style({
					fill:new Fill({//填充样式
						color:"rgba(0,0,0,0)"
					}),
					stroke:new Stroke({//描绘
						width:2,//宽
						color:color
					}),
					zIndex: 100
				});
				return style;
			},
			getSelectPolyonStyle(){//选中要素样式
				let style = new Style({
					fill:new Fill({//填充样式
						color:"rgba(255,255,255,0.2)"
					}),
					stroke:new Stroke({//描绘
						width:2,//宽
						color:"rgba(30,144,255,1)"
					})
				});
				return style;
			},
			showHideTaskDiv() {
				if(this.showHideTask){
					this.showHideTask = false;
					document.getElementById(this.str+"-taskDiv").style.display="block";
					document.getElementById(this.str+"-setTaskDiv-span").innerHTML="结束新建";
					//隐藏工具箱
					this.showHideToolsBox = true;
					document.getElementById(this.str+"-ToolsBoxDiv").style.display="none";
				}else{
					this.showHideTask = true;
					document.getElementById(this.str+"-taskDiv").style.display="none";
					document.getElementById(this.str+"-setTaskDiv-span").innerHTML="新建任务";
					//地图工具箱--结束新建
					this.setMapToolBox('StopDraw');
				}
			},
			isDataLayer() {// 是否显示数据图层列表
				if(this.showHideSurveyBool) {
					this.showHideSurveyBool=false;
					this.$emit('isDataLayer', true)
				}else{
					this.showHideSurveyBool=true;
					this.$emit('isDataLayer', false)
				}
				
			},
			hideContextMenu(){//隐藏右键菜单
				//隐藏右键菜单
				this.newContextMenu.setPosition(null);
				this.taskContextMenu.setPosition(null);
				this.newBufferMenu.setPosition(null)
				this.newCircleMenu.setPosition(null)
				this.circleTool = false
			},
			exportTask() {
				this.$emit("uploadShp",null);
			},
			//行政区划选择工作区域
			xzqhSelectTaskPolygon(){
				this.$emit("xzqhSelect",null);
			},
			clearSelectFeature(){//取消选中要素
				if(this.selectFeature!=null){
					let temp = this.selectFeature.getProperties();
					if(temp.groupData!=undefined && temp.groupData!=null) {//修改任务
						let style = this.getPolyonStyle("orange");
						this.selectFeature.setStyle(style);
					}else if(temp.area!=undefined && temp.area!=null){//新建任务
						let style = this.getPolyonStyle("red");
						this.selectFeature.setStyle(style);
					}
					this.selectFeature = null;
				}
			},
			getDisjoint(allSource) {
				let flag = false
				for(let i = allSource.length - 1;i < allSource.length;i--) {
					if( i - 1 != -1) {
						let coords1 = allSource[allSource.length - 1].getGeometry().getCoordinates()[0].filter(item => item.length !== 0)
						let coords2 = allSource[i - 1].getGeometry().getCoordinates()[0].filter(item => item.length !== 0)
						let polygon1 = turf.polygon([coords1])
						let polygon2 = turf.polygon([coords2])
						let flag = turf.intersect(polygon1, polygon2);
						if(flag != undefined) {
							this.addTaskIsIntersect = true
							break
						}
					}else{
						let arr = [...allSource.slice(0, allSource.length - 1)];
						if(arr.length == 1) {
							this.addTaskIsIntersect = false
							break
						}else{
							this.getDisjoint(arr)
							break
						}
					}
				}
				return flag
			},
			//新建任务
			mapNewTask(){
				this.clearFeatureList = []
				let allSource = this.source.getFeatures()
				let list = []
				allSource.forEach(item =>{
						let type = item.getProperties().geometry.getType()
						if(type == 'Polygon') {
							list.push(item)
						}
				})
				if(list.length > 1) {
					for(let i = list.length - 1;i < list.length;i--) {
						if( i - 1 != -1) {
							let coords1 = list[list.length - 1].getGeometry().getCoordinates()[0].filter(item => item.length !== 0)
							let coords2 = list[i - 1].getGeometry().getCoordinates()[0].filter(item => item.length !== 0)
							let polygon1 = turf.polygon([coords1])
							let polygon2 = turf.polygon([coords2])
							let flag = turf.intersect(polygon1, polygon2);
							if(flag != undefined) {
								this.addTaskIsIntersect = true
								break
							}
						}else{
							let arr = [...list.slice(0, list.length - 1)];
							if(arr.length == 1) {
								this.addTaskIsIntersect = false
								break
							}else{
								this.getDisjoint(arr)
								break
							}
						}
					}
				}
				if(this.addTaskIsIntersect) {
					this.hideContextMenu();
					// let temp = {
					// 	flag: this.addTaskIsIntersect
					// }
					this.$emit("mapNewTask",true);
				}else{
					let arrayAll = []
					let index = 1
					let mutiPolygon = []
					let arrayList = []
					allSource.forEach(item =>{
						let type = item.getProperties().geometry.getType()
						if (type != 'Point' && type != 'LineString' && type != 'MultiPoint' && type != 'MultiLineString' ) {
							arrayList.push(item.values_.parentdistrictList)
							let circleArea
							let properties = item.getProperties()
							let coords,polygonWkt
							if (type == 'Circle') {
								coords = fromCircle(item.getGeometry()).getCoordinates()[0]
								circleArea = fromCircle(item.getGeometry())
							} else {
								coords = item.getGeometry().getCoordinates()[0]
								circleArea = item.getGeometry()
							}
							mutiPolygon.push(circleArea)
							if (properties.area == '' || properties.area == undefined) {
								let area = getArea(circleArea, {projection: 'EPSG:4490'})
								let output = Math.round((area / 1000000) * 100) / 100;
								item.setProperties({area: output});
							}
							if(coords.length>0){
								polygonWkt = "POLYGON((";
								for(let i=0;i<coords.length;i++){
									if(i>0){
										polygonWkt += ",";
									}
									let lonlat = coords[i];
									polygonWkt += lonlat[0]+" "+lonlat[1];
								}
								polygonWkt += "))";
							}
							let featureList = {
								tdaArea: properties.area,
								tdaName: '区域' + index++,
								geom: polygonWkt
							}
							arrayAll.push(featureList)
							this.clearFeatureList.push(item)
						}
					})
					let multiPolygon = new MultiPolygon(mutiPolygon)
					let multicoords = multiPolygon.getCoordinates()
					let multipolygonWkt
					if(multicoords.length>0){
						multipolygonWkt = "MULTIPOLYGON(";
						for(let i=0;i<multicoords.length;i++){
							if(i>0){
								multipolygonWkt += ",";
							}
							let lonlat = multicoords[i][0];
							let filteredArr = lonlat.filter(item => item.length !== 0)
							let ploygon = '(('
							for(let j=0;j<filteredArr.length;j++){
								if(j == filteredArr.length - 1) {
									ploygon += filteredArr[j][0] + ' ' + filteredArr[j][1]
								} else {
									ploygon += filteredArr[j][0] + ' ' + filteredArr[j][1] + ','
								}
							}
							multipolygonWkt += ploygon + '))';
						}
						multipolygonWkt += ")";
					}
					let temp = {
						taskRegion: multipolygonWkt,
						polygonList: arrayAll,
						parentdistrictList: this.parentdistrictList,
						arrayList: arrayList
					}
					this.hideContextMenu();
					this.$emit("mapNewTask",temp);
				}
				//隐藏右键菜单
				// this.hideContextMenu();
			},
			//修改任务
			mapUpdTask(){
				let row = this.selectTaskRow;
				this.$emit("mapUpdTask",row);
				//隐藏右键菜单
				this.hideContextMenu();
			},
			//删除任务
			mapDelTask(){
				let row = this.selectTaskRow;
				this.$emit("mapDelTask",row);
				//隐藏右键菜单
				this.hideContextMenu();
			},
			//地图工具箱
			setMapToolBox(value){
				let that = this;
				if (value === 'Clear') {//清空
					//清空
					that.source.clear();
					//停止绘制|修改|拖拽|选择
					clearInteraction();
				}else if (value === 'Point' || value === 'LineString' || value === 'Polygon' || value === 'Circle') {//开启绘制
					//点|线|面|圆绘制
					//开启绘制
					startDrawInteraction(value,false);
				}else if (value === 'FreeHandLineString' || value === 'FreeHandPolygon') {//开启绘制
					//手绘线|手绘面
					value = value.split("FreeHand")[1];
					//开启绘制
					startDrawInteraction(value,true);
				}else if (value === 'StopDraw') {//停止绘制
					//停止绘制
					stopDrawInteraction();
				}else if (value === 'Snap') {//开启捕捉
					//开启捕捉
					startSnapInteraction();
				}else if (value === 'NotSnap') {//停止捕捉
					//停止捕捉
					stopSnapInteraction();
				}else if (value === 'Modify') {//开启修改
					//开启修改
					startModifyInteraction();
				}else if (value === 'NotModify') {//停止修改
					//停止修改
					stopModifyInteraction();
					//停止选择
					stopSelectInteraction();
				}else if (value === 'Drag') {//开启拖拽
					//开启拖拽
					startDragInteraction();
				}else if (value === 'NotDrag') {//停止拖拽
					//停止拖拽
					stopDragInteraction();
				}else if (value === 'Select') {//开启选择
					//开启选择
					startSelectInteraction();
				}else if (value === 'NotSelect') {//停止选择
					//停止选择
					stopSelectInteraction();
				} else if (value === 'MeasureDistance') {//开启测距
					//开启测距
					startMeasureInteraction('LineString');
				} else if (value === 'MeasureArea') {//开启测面
					//开启测面
					startMeasureInteraction('Polygon');
				} else if (value === 'StopMeasure') {//停止测量（测距|测面）
					//停止测量
					stopMeasureInteraction();
				} else if (value === 'ClearMeasure') {//清空测量结果
					//停止测量
					stopMeasureInteraction();
					//清空测量结果
					clearMeasureResult();
				}

				//停止绘制|修改|拖拽|选择
				function clearInteraction() {
					//停止拖拽
					stopDragInteraction();
					//停止修改
					stopModifyInteraction();
					//停止选择
					stopSelectInteraction();
					//停止绘制
					stopDrawInteraction();
				}

				//停止捕捉
				function stopSnapInteraction(){
					if (that.snap) {
						that.map.removeInteraction(that.snap);
						that.snap = null;
					}
				}

				//开启捕捉
				function startSnapInteraction(){
					//停止捕捉
					stopSnapInteraction();
					//开启捕捉
					that.snap = new Snap({
						source: that.source
					});
					that.map.addInteraction(that.snap);
				}

				//停止拖拽
				function stopDragInteraction() {
					//停止拖拽
					if (that.drag) {
						that.map.removeInteraction(that.drag);
						that.drag = null;
					}
				}

				//开启拖拽
				function startDragInteraction() {
					//停止绘制
					stopDrawInteraction();
					//停止修改
					stopModifyInteraction();
					//开启选择
					startSelectInteraction();
					//停止拖拽
					stopDragInteraction();
					//开启拖拽
					that.drag = new Translate({
						features: that.select.getFeatures()
					});
					that.map.addInteraction(that.drag);
				}

				//停止修改
				function stopModifyInteraction() {
					//停止修改
					if (that.modify) {
						that.map.removeInteraction(that.modify);
						that.modify = null;
					}
				}

				//开启修改
				function startModifyInteraction() {
					//停止绘制
					stopDrawInteraction();
					//开启选择
					startSelectInteraction();
					//停止修改
					stopModifyInteraction();
					//开启修改
					// that.modify = new Modify({
					// 	features: that.select.getFeatures()
					// });
					let b = that.map.getInteractions()
					that.modify = new Modify({
						source: that.source
					});
					that.map.addInteraction(that.modify);
				}

				//停止选择
				function stopSelectInteraction() {
					//停止选择
					if (that.select) {
						that.map.removeInteraction(that.select);
						that.select = null;
					}
				}

				//开启选择
				function startSelectInteraction() {
					//停止选择
					stopSelectInteraction();
					//开启选择
					that.select = new Select({
						wrapX: false
					});
					that.map.addInteraction(that.select);
				}

				//停止绘制
				function stopDrawInteraction() {
					//停止绘制
					if (that.draw) {
						that.map.removeInteraction(that.draw);
						that.draw = null;
					}
				}

				//开启绘制
				function startDrawInteraction(type,bool) {
					//停止拖拽
					stopDragInteraction();
					//停止修改
					stopModifyInteraction();
					//停止选择
					stopSelectInteraction();
					//停止绘制
					stopDrawInteraction();
					if(bool){//手绘线|手绘面
						that.draw = new Draw({
							source: that.source,
							type: type,
							snapTolerance: 20,
							freehand: true
						});
						that.map.addInteraction(that.draw);
					}else{//点|线|面|圆绘制
						that.draw = new Draw({
							source: that.source,
							type: type,
							snapTolerance: 20
						});
						that.map.addInteraction(that.draw);
						that.drawState = type
						//绘制结束时触发的事件
						that.draw.on('drawend', function(e) {
							if (e.feature && e.feature.getGeometry() instanceof CircleDraw) {
								let radius = document.getElementById('drawCircleRadius').value
								if (radius != '') {
									radius = radius * 1000
									let metersPerUnit = that.map.getView().getProjection().getMetersPerUnit();
									let circleRadius =  radius / metersPerUnit;
									e.feature.getGeometry().setRadius(circleRadius)
								}
							}
							// let circlrCenter = e.feature.getGeometry().getCenter()
							// let radius = e.feature.getGeometry().getRadius()
							// let a = transform(circlrCenter, 'EPSG:4326', 'EPSG:3857')
							// let b = [a[0] + radius, a[1]]
							// let c = Math.round(getLength(new LineString([b,circlrCenter])))
							let geometry = e.feature.getGeometry();
							//停止绘制
							stopDrawInteraction();
							let style
							//设置样式
							if (type == 'Point') {
								style = that.drawPointStyle()
							} else {
								style = that.getPolyonStyle("red");
							}
							e.feature.setStyle(style);
							//计算面积
							if (geometry instanceof Polygon || geometry instanceof CircleDraw) {
								let area = getPolygonArea(geometry);
								//清空查询行政区划列表
								that.parentdistrictList = [];
								//清空区域查询行政区划名称列表
								that.parentdistrictNameList = [];
								//清空区域查询行政区划编码列表
								that.parentdistrictCodeList = [];
								//正在查询
								that.mapLoading("正在查询，请稍候...");
								//新查询绘制区域经纬度任务地区
								that.queryDrawAreaNew(e.feature);
								/*//几何查询--省值
								that.queryProvince(e.feature);
								//几何查询--省会市值
								that.queryProCenCity(e.feature);
								//几何查询--市值
								that.queryCity(e.feature);
								//几何查询--区县值
								that.queryArea(e.feature);
								//获取多边形面内的均匀点分布数组
								let allLonLatArr = that.getPolygonExtentPoints(geometry);
								//查询绘制区域经纬度点地址
								that.queryDrawArea(e.feature,allLonLatArr);*/
								//设置属性
								e.feature.setProperties({area: area});
							}
						});
					}
				}
				//计算面积
				function getPolygonArea (geometry) {
					let area 
					let output
					let circleArea = geometry
					if (geometry instanceof CircleDraw) {
						circleArea = fromCircle(geometry)
					}
					area = getArea(circleArea, {projection: 'EPSG:4490'})
					// 这里一定要给坐标，和地图坐标保持一致，否则面积不准
					output = Math.round((area / 1000000) * 100) / 100;//平方公里
					return output;
				}

				////////////////////////////////////////////////////////////////////测量工具箱
				//格式化距离
				function formatLength(line) {
					const length = getLength(line, {projection: 'EPSG:4490'});
					let output;
					if (length > 100) {
						output = Math.round((length / 1000) * 100) / 100 + ' ' + 'km';
					} else {
						output = Math.round(length * 100) / 100 + ' ' + 'm';
					}
					return output;
				}

				//格式化面积
				function formatArea(polygon) {
					const area = getArea(polygon, {projection: 'EPSG:4490'});
					let output;
					if (area > 10000) {
						output = Math.round((area / 1000000) * 100) / 100 + ' ' + 'km<sup>2</sup>';
					} else {
						output = Math.round(area * 100) / 100 + ' ' + 'm<sup>2</sup>';
					}
					return output;
				}

				//创建新的提示tip
				function createHelpTooltip() {
					if (that.helpTooltipElement!=null) {
						that.helpTooltipElement.parentNode.removeChild(that.helpTooltipElement);
					}
					that.helpTooltipElement = document.createElement('div');
					that.helpTooltipElement.className = 'ol-tooltip hidden';
					that.helpTooltip = new Overlay({
						element: that.helpTooltipElement,
						offset: [15, 0],
						positioning: 'center-left',
					});
					that.map.addOverlay(that.helpTooltip);
				}

				//创建新的测量提示
				function createMeasureTooltip() {
					if (that.measureTooltipElement!=null) {
						that.measureTooltipElement.parentNode.removeChild(that.measureTooltipElement);
					}
					that.measureTooltipElement = document.createElement('div');
					that.measureTooltipElement.className = 'ol-tooltip ol-tooltip-measure';
					that.measureTooltip = new Overlay({
						element: that.measureTooltipElement,
						offset: [0, -15],
						positioning: 'bottom-center',
						stopEvent: false,
						insertFirst: false,
					});
					that.map.addOverlay(that.measureTooltip);
				}
				//开启测量工具
				function startMeasureInteraction(type) {
					//停止测量工具
					stopMeasureInteraction();

					console.log(type);
					//开启测量工具--绘制
					that.measure = new Draw({
						source: that.measureSource,
						type: type,
						style: new Style({
							fill: new Fill({
								color: 'rgba(255, 255, 255, 0.2)',
							}),
							stroke: new Stroke({
								color: 'rgba(0, 0, 0, 0.5)',
								lineDash: [10, 10],
								width: 2,
							}),
							image: new Circle({
								radius: 5,
								stroke: new Stroke({
									color: 'rgba(0, 0, 0, 0.7)',
								}),
								fill: new Fill({
									color: 'rgba(255, 255, 255, 0.2)',
								}),
							}),
						}),
					});
					that.map.addInteraction(that.measure);

					//创建新的测量提示
					createMeasureTooltip();
					//创建新的提示tip
					createHelpTooltip();

					let listener;
					that.measure.on('drawstart', function (evt) {
						//设置sketch
						that.sketch = evt.feature;

						let tooltipCoord = evt.coordinate;

						listener = that.sketch.getGeometry().on('change', function (evt) {
							const geom = evt.target;
							let output;
							if (geom instanceof Polygon) {
								output = formatArea(geom);
								tooltipCoord = geom.getInteriorPoint().getCoordinates();
							} else if (geom instanceof LineString) {
								output = formatLength(geom);
								tooltipCoord = geom.getLastCoordinate();
							}
							that.measureTooltipElement.innerHTML = output;
							that.measureTooltip.setPosition(tooltipCoord);
						});
					});
					//完成测量绘制
					that.measure.on('drawend', function () {
						that.measureTooltipElement.className = 'ol-tooltip ol-tooltip-static';
						that.measureTooltip.setOffset([0, -7]);
						//添加到数组
						that.measureTooltipArray.push(that.helpTooltip);
						//添加到数组
						that.measureTooltipArray.push(that.measureTooltip);
						//清空sketch
						that.sketch = null;
						//清空tooltip
						that.measureTooltipElement = null;
						createMeasureTooltip();
						unByKey(listener);
					});
				}

				//停止测量工具
				function stopMeasureInteraction() {
					//停止绘制
					stopDrawInteraction();
					//停止测量工具
					if (that.measure) {
						that.map.removeInteraction(that.measure);
						that.measure = null;
						//隐藏提示tip
						that.helpTooltipElement.classList.add('hidden');
						//移除测量提示
						if(that.helpTooltip!=null){
							that.map.removeOverlay(that.helpTooltip);
						}
						if(that.measureTooltip!=null){
							that.map.removeOverlay(that.measureTooltip);
						}
					}
				}
				
				//清空测量结果
				function clearMeasureResult(){
					if(that.measureSource!=null){
						//清空测量结果
						that.measureSource.clear();
						//清空测量结果提示数组
						if(that.measureTooltipArray.length>0){
							for(let i=0;i<that.measureTooltipArray.length;i++){
								that.map.removeOverlay(that.measureTooltipArray[i]);
							}
							that.measureTooltipArray = [];
						}
					}
				}
			},
			//完成修改区域
			saveEditPolygon(){
				//隐藏右键菜单
				this.hideContextMenu();
				//地图工具箱--停止修改
				this.setMapToolBox('NotModify');
				//取消选中要素
				this.clearSelectFeature();
			},
			//修改区域
			editPolygon(){
				//地图工具箱--开启修改
				this.setMapToolBox('Modify');
				//隐藏右键菜单
				this.hideContextMenu();
			},
			//删除区域
			deletePolygon(){
				//隐藏右键菜单
				this.hideContextMenu();
				if(this.selectFeature!=null) {
					let temp = this.selectFeature.getProperties();
					if(temp.groupData!=undefined && temp.groupData!=null) {//修改任务
						//移除选中要素区域
						this.taskVectorLayer.getSource().removeFeature(this.selectFeature);
					}else{//新建任务
						//移除选中要素区域
						this.source.removeFeature(this.selectFeature);
					}
				}
			},
			queryDrawAreaNew(feature){//新查询绘制区域经纬度任务地区
				let that = this;
				this.drawAreaFeature = feature;//地图圈选要素
				let polygon = feature.getGeometry();
				if (polygon instanceof CircleDraw) {
					polygon = fromCircle(polygon)
				}
				let pointArray = polygon.getCoordinates();
				let pointArr = pointArray[0];
				let geomText = "";
				if(pointArr!=null && pointArr.length>0){
					geomText = "MULTIPOLYGON(((";
					for(let i=0;i<pointArr.length;i++){
						let lonlat = pointArr[i];
						if(i>0){
							geomText += ",";
						}
						geomText += lonlat[0] + ' ' + lonlat[1];
					}
					geomText += ")))";
					//根据地图圈选区域，查询行政区划--省|市|区县的名称和code列表
					this.$emit("queryTaskRegionNameCodeListByGeomText",geomText);
				}
			},
			mapLoading(msg){//地图查询Loading
				if(this.mapLoadingBool){
					this.$emit("mapLoading",msg);
				}
			},
			queryDrawAreaNewResult(list){//完成查询绘制区域经纬度任务地区
				if(this.drawAreaFeature!=null){
					console.log("完成查询绘制区域经纬度任务地区");
					if(list!=null && list.length==2){
						let nameList = list[0];//行政区划名称列表
						let codeList = list[1];//行政区划编码列表
						for(let i=0;i<nameList.length;i++){
							let nameArr = nameList[i].split("-");
							let codeArr = codeList[i].split("-");
							for(let j=0;j<nameArr.length;j++){
								let name = nameArr[j];
								let code = codeArr[j];
								if(code!=null && this.isObjInArray(this.parentdistrictCodeList,code)==-1){
									this.parentdistrictCodeList.push(code);
									this.parentdistrictNameList.push(name);
								}
							}
						}
					}
					//设置绘制区域点查询完毕参数
					this.queryDrawAreaBool = true;
					//匹配省市县信息
					this.getProvinceCityArea(this.drawAreaFeature);
					//完成查询
					this.mapLoading(null);
				}
			},
			//匹配省市县信息
			getProvinceCityArea(feature){
				console.log("匹配省市县信息---");
				console.log(this.parentdistrictNameList);
				console.log(this.parentdistrictCodeList);
				if(this.parentdistrictCodeList.length>0){
					let string = "";
					let nameString = "";
					let tempNamelist = [];
					let tempCodelist = [];
					let tempObjList = [];
					let list = [];//匹配省市县信息结果列表
					let codeList = [];//匹配省市县信息Code结果列表
					for(let i=0;i<this.parentdistrictCodeList.length;i++){
						let code = this.parentdistrictCodeList[i];
						if(i>0){
							string += ",";
						}
						string += code;
						let name = this.parentdistrictNameList[i];
						nameString += name;
						// name = this.getProvinceCityAreaByName(name);//根据行政区划名称获取省市区信息
						name = this.getProvinceCityAreaByCode(code);//根据行政区划编码获取省市区信息
						this.parentdistrictNameList[i] = name;
						//添加到返回结果的新建任务参数--行政区划
						if(name!=null && this.isObjInArray(tempNamelist,name)==-1){
							tempNamelist.push(name);
							tempCodelist.push(code);
							let obj = {
								name:name,
								code:Number(code)
							}
							tempObjList.push(obj);
						}
					}
					console.log(tempObjList);
					//升序排序
					function sortby(prop) {
						// prop 属性名
						// rev  升序降序 默认升序
						return function(a, b) {
							let val1 = a[prop];
							let val2 = b[prop];
							return val1 - val2;
						}
					}
					tempObjList.sort(sortby('code'));//按code升序排序
					console.log("去除重复省市县信息");
					console.log(tempObjList);
					//去除重复省市县信息
					if(tempObjList.length>0){
						let tempProvinceCodeArray = [];
						let tempCityCodeArray = [];
						//获取全部省市信息
						for(let i=0;i<tempObjList.length;i++) {
							let obj = tempObjList[i];
							let name = obj.name;
							let code = obj.code;
							code = code.toString();
							let arr = name.split("-");
							if (arr.length == 1) {//省或直辖市
								if(this.isObjInArray(tempProvinceCodeArray,code)==-1){
									console.log(name+"--省--");
									tempProvinceCodeArray.push(code);
								}
							}else if (arr.length == 2) {//市或直辖市的区县
								let tempProvince = arr[0];
								code = code.substring(0,2) + "0000";
								if(this.isObjInArray(tempProvinceCodeArray,code)==-1){
									console.log(name+"--市截取省--"+tempProvince);
									tempProvinceCodeArray.push(code);
								}
							}else if (arr.length == 3) {//区县
								let tempCity = arr[0]+"-"+arr[1];
								code = code.substring(0,4) + "00";
								if(this.isObjInArray(tempCityCodeArray,code)==-1){
									console.log(name+"--区县截取市--"+tempCity);
									tempCityCodeArray.push(code);
								}
							}
						}
						//判断省是否包含全部市，直辖市是否包含全部区县，市是否包含全部区县，合并省和市信息
						let mergeProvinceCodeArray = [];
						let mergeCityCodeArray = [];
						if(tempCityCodeArray!=null && tempCityCodeArray.length>0){
							for(let i=0;i<tempCityCodeArray.length;i++){
								let tempCityCode = tempCityCodeArray[i];
								let tempCityChildrenArray = this.getCityChildrenArrayByCode(tempCityCode);//根据市code获取children字符串列表
								let count = 0;
								for (let j = 0; j < tempObjList.length; j++) {
									let obj1 = tempObjList[j];
									let code1 = obj1.code;
									if(this.isObjInArray(tempCityChildrenArray,code1)!=-1){//区县
										count++;
									}
								}
								if (count==tempCityChildrenArray.length) {//市是否包含全部区县
								//if (count>(tempCityChildrenArray.length-3)) {//市是否包含全部区县-3
									if(this.isObjInArray(mergeCityCodeArray,tempCityCode)==-1){
										mergeCityCodeArray.push(tempCityCode);
									}
								}
							}
						}
						console.log("mergeCityCodeArray"+mergeCityCodeArray);
						if(tempProvinceCodeArray!=null && tempProvinceCodeArray.length>0){
							for(let i=0;i<tempProvinceCodeArray.length;i++){
								let tempProvinceCode = tempProvinceCodeArray[i];
								let tempProvinceChildrenArray = this.getProvinceChildrenArrayByCode(tempProvinceCode);//根据省code获取children字符串列表
								let count = 0;
								console.log(tempProvinceCode+"tempProvinceCode");
								if(tempProvinceCode=="110000" || tempProvinceCode=="120000" || tempProvinceCode=="310000" || tempProvinceCode=="500000"){
									//直辖市
									for (let j = 0; j < tempObjList.length; j++) {
										let obj1 = tempObjList[j];
										let code1 = obj1.code;
										if(this.isObjInArray(tempProvinceChildrenArray,code1)!=-1){//区县
											count++;
										}
									}
									console.log(count+",直辖市"+tempProvinceChildrenArray);
								}else{//省
									for (let j = 0; j < mergeCityCodeArray.length; j++) {
										let code1 = mergeCityCodeArray[j];
										if(code1=="710100"){//台湾省-台湾省
											code1 = "710000";
										}
										if(this.isObjInArray(tempProvinceChildrenArray,code1)!=-1){//市
											count++;
										}
									}
								}
								if (count==tempProvinceChildrenArray.length) {//省是否包含全部市，直辖市是否包含全部区县
								//if (count>(tempProvinceChildrenArray.length-3)) {//省是否包含全部市，直辖市是否包含全部区县-3
									if(this.isObjInArray(mergeProvinceCodeArray,tempProvinceCode)==-1){
										mergeProvinceCodeArray.push(tempProvinceCode);
									}
								}
							}
						}
						console.log("mergeProvinceCodeArray------"+mergeProvinceCodeArray.length);
						console.log(mergeProvinceCodeArray);
						console.log("mergeCityCodeArray--------"+mergeCityCodeArray.length);
						console.log(mergeCityCodeArray);
						//添加其他未合并的区县数据
						for(let i=0;i<tempObjList.length;i++){
							let obj = tempObjList[i];
							let name = obj.name;
							let code = obj.code;
							code = code.toString();
							let arr = name.split("-");
							if (arr.length == 1) {//省
								if(this.isObjInArray(mergeProvinceCodeArray,code)!=-1 && this.isObjInArray(list,name)==-1){
									list.push(name);
									codeList.push(code);
								}
							}else if (arr.length == 2) {//市或直辖市的区县
								let tempCode = code.substring(0,2) + "0000";
								if(this.isObjInArray(mergeProvinceCodeArray,tempCode)!=-1){//判断是否市合并为省、直辖市的区县合并为直辖市
									if(this.isObjInArray(list,arr[0])==-1){
										list.push(arr[0]);
										codeList.push(tempCode);
									}
								}else{//不合并市或直辖市的区县
									if(this.isObjInArray(list,name)==-1){//判断是否包含
										list.push(name);
										codeList.push(code);
									}
								}
							}else if (arr.length == 3) {//区县
								let bool = true;
								if(list.length>0){
									for(let j=0;j<list.length;j++){
										let temp = list[j];
										if(name.indexOf(temp)!=-1){//判断是否包含
											bool = false;
											break;
										}
									}
								}
								if(bool){
									if(this.isObjInArray(list,name)==-1){//判断是否包含
										list.push(name);
										codeList.push(code);
									}
								}
							}
						}
					}
					console.log(list);
					console.log(codeList);
					console.log("合并省市区县信息结果");
					this.parentdistrictList = list;
					console.log(string);
					console.log("根据行政区划名称获取省市区信息");
					console.log(nameString);
					console.log(this.parentdistrictList);
					//设置属性
					feature.setProperties({parentdistrictList:this.parentdistrictList});
				}
				//设置参数
				this.queryProvinceBool=false;
				this.queryCityBool=false;
				this.queryProCityBool=false;
				this.queryAreaBool=false;
				this.queryDrawAreaBool = false;
				this.queryDrawAreaPointCount = 0;
			},
			getProvinceCityAreaByName(name){//根据行政区划名称获取省市区信息
				//根节点ID
				let rootPid = "af50c20a9b9f474e88dbbf742a7e5377";
				//获取行政区划树列表
				let treeList = this.districtTreeDataList;
				if(treeList!=null && treeList.length>0){
					for(let i=0;i<treeList.length;i++){
						let provinceData = treeList[i];//省节点
						if(provinceData!=null){
							let provinceName = provinceData.name;//省
							if(name==provinceName){
								return provinceName;
							}
							let cityList = provinceData.children;//市列表
							if(cityList!=null){
								for(let j=0;j<cityList.length;j++){
									let cityData = cityList[j];
									if(cityData!=null){
										let cityName = cityData.name;//市
										if(name==cityName){
											return provinceName+"-"+cityName;
										}
										let areaList = cityData.children;//区县列表
										if(areaList!=null){
											for(let j=0;j<areaList.length;j++){
												let areaData = areaList[j];
												if(areaData!=null){
													let areaName = areaData.name;//区县
													if(name==areaName){
														return provinceName+"-"+cityName+"-"+areaName;
													}
												}
											}
										}
									}
								}
							}
						}
					}
				}
				console.log("查询不到："+name);
				return name;
			},
			getProvinceChildrenArrayByCode(code){//根据省code获取市code列表，根据直辖市code获取区县code列表
				let childrenArray = [];
				//获取行政区划树列表
				let treeList = this.districtTreeDataList;
				if(treeList!=null && treeList.length>0){
					for(let i=0;i<treeList.length;i++){
						let provinceData = treeList[i];//省节点
						if(provinceData!=null){
							let provinceCode = provinceData.code;//省编码
							if(code==provinceCode){
								let cityList = provinceData.children;//市列表
								if(cityList!=null){
									for(let j=0;j<cityList.length;j++){
										let cityData = cityList[j];
										if(cityData!=null){
											let cityCode = cityData.code;//市编码
											childrenArray.push(cityCode);
										}
									}
								}
							}
						}
					}
				}
				if(childrenArray.length>0){
					console.log("ProvinceChildrenArray："+childrenArray);
				}else{
					console.log("查询不到ProvinceChildrenArray："+code);
				}
				return childrenArray;
			},
			getCityChildrenArrayByCode(code){//根据市code获取区县code列表
				let childrenArray = [];
				//获取行政区划树列表
				let treeList = this.districtTreeDataList;
				if(treeList!=null && treeList.length>0){
					for(let i=0;i<treeList.length;i++){
						let provinceData = treeList[i];//省节点
						if(provinceData!=null){
							let cityList = provinceData.children;//市列表
							if(cityList!=null){
								for(let j=0;j<cityList.length;j++){
									let cityData = cityList[j];
									if(cityData!=null){
										let cityCode = cityData.code;//市编码
										if(cityCode=="710000"){//台湾省-台湾省
											cityCode = "710100";
										}
										if(code==cityCode){
											let areaList = cityData.children;//区县列表
											if(areaList!=null){
												for(let j=0;j<areaList.length;j++){
													let areaData = areaList[j];
													if(areaData!=null){
														let areaName = areaData.name;//区县
														let areaCode = areaData.code;//区县编码
														childrenArray.push(areaCode);
													}
												}
											}
											break;
										}
									}
								}
							}
						}
					}
				}
				if(childrenArray.length>0){
					console.log("CityChildrenArray："+childrenArray);
				}else{
					console.log("查询不到CityChildrenArray："+code);
				}
				return childrenArray;
			},
			getProvinceCityAreaByCode(code){//根据行政区划编码获取省市区信息
				//根节点ID
				let rootPid = "1";
				if(this.districtTreeDataList!=null && this.districtTreeDataList!=""){
					//获取行政区划树列表
					let treeList = this.districtTreeDataList;
					if(treeList!=null && treeList.length>0){
						for(let i=0;i<treeList.length;i++){
							let provinceData = treeList[i];//省节点
							if(provinceData!=null){
								let provinceName = provinceData.name;//省
								let provinceCode = provinceData.code;//省编码
								if(code==provinceCode){
									return provinceName;
								}
								let cityList = provinceData.children;//市列表
								if(cityList!=null){
									for(let j=0;j<cityList.length;j++){
										let cityData = cityList[j];
										if(cityData!=null){
											let cityName = cityData.name;//市
											let cityCode = cityData.code;//市编码
											if(code==cityCode){
												return provinceName+"-"+cityName;
											}
											let areaList = cityData.children;//区县列表
											if(areaList!=null){
												for(let j=0;j<areaList.length;j++){
													let areaData = areaList[j];
													if(areaData!=null){
														let areaName = areaData.name;//区县
														let areaCode = areaData.code;//区县编码
														if(code==areaCode){
															return provinceName+"-"+cityName+"-"+areaName;
														}
													}
												}
											}
										}
									}
								}
							}
						}
					}
				}
				console.log("查询不到code："+code);
				return code;
			},
			isObjInArray(array,obj){//判断数组中是否包含对象
				let index = -1;
				if(array!=null && array.length>0){
					for(let i=0;i<array.length;i++){
						if(obj==array[i]){
							index = i;
							break;
						}
					}
				}
				return index;
			},
			autodivheight() {//自动获取div高度
				//获取浏览器窗口高度
				let winHeight = 0;
				if (window.innerHeight) {
						winHeight = window.innerHeight;
				} else if ((document.body) && (document.body.clientHeight)) {
						winHeight = document.body.clientHeight;
				}
				//通过深入Document内部对body进行检测，获取浏览器窗口高度
				if (document.documentElement && document.documentElement.clientHeight) {
						winHeight = document.documentElement.clientHeight;
				}
				//全屏时窗口高度:864px,地图div高度:754px
				let tempHeight = 864;
				let mapTempHeight = 754;
				let mapHeight = winHeight - tempHeight + mapTempHeight;
				//最小高度
				if(mapHeight<480){
						mapHeight = 480;
				}
				//设置地图高度
				document.getElementById(this.str+"-map").style.height= mapHeight +"px";
				console.log("窗口高度："+winHeight+"地图高度："+mapHeight);
				//resize事件--刷新地图,确保地图不变形
				if(this.map){
						this.map.updateSize();
						console.log("resize事件--刷新地图,确保地图不变形");
				}
			},
    }
})
</script>
